package com.shengyijie.activity.tab;
  

import com.shengyijie.activity.MainActivity;
import com.shengyijie.activity.R;     
import com.shengyijie.activity.share.ShareSelectActivity;  
import com.shengyijie.context.ContextApplication; 
import com.shengyijie.util.DataStore;

import android.app.Activity;  
import android.content.Intent; 
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.View.OnClickListener;  
import android.widget.Button; 
import android.widget.ImageButton;  
import android.widget.TextView;  

public class AboutActivity extends Activity implements OnClickListener{
       
	 public static int Page_Type;
	 public static final int Page_About=1;
	 public static final int Page_Help=0;
	 public static final int Page_Contact=2;
	
	 private ImageButton tabHome;
	 private ImageButton tabCategory;
	 private ImageButton tabRecommended;
	 private ImageButton tabUser;
	 private ImageButton tabMore;
	 
	 private TextView tv_about; 
	  
	 private String help="1.在生意街中，您可以通过分类浏览来找项目，看到感兴趣的项目记得及时留言哦，我们的招商经理会在第一时间与您取得联系。\n2.您还可以通过手机客服端来注册生意街会员。个人用户可以浏览生意街为您推送的及时信息，也可以在用户中心查看已经关注和留言过的项目。企业用户可以在用户中心随时关注网友给贵项目的最新留言。\n3.如果找不到合适的项目，可以通过点击更多到搜索框内输入关键字查找适合的项目。也可以在更多中查看关于生意街的信息，祝您使用愉快！"; 
	 private String about="    生意街是中国最诚信的招商信息互动平台，关注平台的创业者很多，平均每天有5万人在生意街平台上寻找商机，有近万人都是有经验的经销商和加盟商，投资能力在20万以上，据不完全统计，每天近百个投资者通过生意街平台成功签约。";
	 private String contact="上海通路快建网络服务外包有限公司\n招商热线：400-0606-875\n客服热线: 021-61727686\n网　址：http://www.shengyijie.net";
    public void onCreate(Bundle savedInstanceState){
         super.onCreate(savedInstanceState);
         requestWindowFeature(Window.FEATURE_CUSTOM_TITLE); 
         setContentView(R.layout.about);
         getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE,      // 注意顺序
                 R.layout.title);
         initView(); 
         setInfo();
        
    }
     
    public void initView(){
    	TextView title=(TextView) this.findViewById(R.id.title);
    	tv_about=(TextView) this.findViewById(R.id.about);
		
		switch(Page_Type){
		     case Page_Help:
		    	 title.setText("帮助中心"); 
		    	 tv_about.setText(help); 
			     break;
		     case Page_About:
		    	 title.setText("关于我们"); 
		    	 tv_about.setText(about); 
			     break;
		     case Page_Contact:
		    	 title.setText("联系我们"); 
		    	 tv_about.setText(contact); 
			     break;
		}
		
		Button back=(Button) this.findViewById(R.id.back);
		back.setVisibility(View.VISIBLE);
		back.setOnClickListener(this);
		
		 
		 
		 
		 
    	tabHome=(ImageButton) this.findViewById(R.id.home);
    	tabCategory=(ImageButton) this.findViewById(R.id.category);
    	tabRecommended=(ImageButton) this.findViewById(R.id.recommended);
    	tabUser=(ImageButton) this.findViewById(R.id.user);
    	tabMore=(ImageButton) this.findViewById(R.id.more);
		try{
		    switch(ContextApplication.prePage){
		       case ContextApplication.PAGE_HOME:
		    	   tabHome.setSelected(true);
			       break;
		       case ContextApplication.PAGE_CATEGORY:
		    	   tabCategory.setSelected(true);
			       break;
		       case ContextApplication.PAGE_RECOMMENDED:
		    	   tabRecommended.setSelected(true);
			       break;
		       case ContextApplication.PAGE_USER:
		    	   tabUser.setSelected(true);
			       break;
		       case ContextApplication.PAGE_MORE:
		    	   tabMore.setSelected(true);
			       break;
		     }
		 }catch(Exception e){}
		
		 tabHome.setOnClickListener(this);
		 tabCategory.setOnClickListener(this);
		 tabRecommended.setOnClickListener(this);
		 tabUser.setOnClickListener(this);
		 tabMore.setOnClickListener(this);
		  
    }
    
    public void setInfo(){
    	try{
    		String content=DataStore.fetch(this, Page_Type);
    		if(!content.equals("")){
    		 	tv_about.setText(content); 
        	}
    	}catch(Exception e){} 
    	
    }
    
    
    
 

	@Override
	public void onClick(View v) { 
		Bundle bd = new Bundle();
        bd.putString("state", "exit");	
        Intent it = new Intent();
        it.putExtras(bd);
		switch(v.getId()){
		     case R.id.home:
			    try{
				   if(ContextApplication.prePage!=ContextApplication.PAGE_HOME){
					   MainActivity.tabhost.setCurrentTab(0);
					   setResult(RESULT_OK, it); 
					   this.finish();
				   }
			    }catch(Exception e){}
			    break;
		     case R.id.category:
				    try{
					   if(ContextApplication.prePage!=ContextApplication.PAGE_CATEGORY){
						   MainActivity.tabhost.setCurrentTab(1);
						   setResult(RESULT_OK, it); 
						   this.finish();
					   }
				    }catch(Exception e){}
				    break;
		     case R.id.recommended:
				    try{
					   if(ContextApplication.prePage!=ContextApplication.PAGE_RECOMMENDED){
						   MainActivity.tabhost.setCurrentTab(2);
						   setResult(RESULT_OK, it); 
						   this.finish();
					   }
				    }catch(Exception e){}
				    break;
		     case R.id.user:
				    try{
					   if(ContextApplication.prePage!=ContextApplication.PAGE_USER){
						   MainActivity.tabhost.setCurrentTab(3);
						   setResult(RESULT_OK, it); 
						   this.finish();
					   }
				    }catch(Exception e){}
				    break;
		     case R.id.more:
				    try{
					   if(ContextApplication.prePage!=ContextApplication.PAGE_MORE){
						   MainActivity.tabhost.setCurrentTab(4);
						   setResult(RESULT_OK, it); 
						   this.finish();
					   }
				    }catch(Exception e){}
				    break;
		     
		     case R.id.back:
				    try{
					  this.finish();
				    }catch(Exception e){}
				    break;
		      
		}
	}
	
   
	 
    
}